script_enemy_main{

let xpos=GetClipMinX+(GetClipMaxX-GetClipMinX)/22;
let ypos=GetClipMinY+(GetClipMaxY-GetClipMinY)/22;
let phase=0;
let shots=0;
let phase2=1;
let stopshoot=0;

let character="Kurumi";
let cutin=character;
let dispelled=0;
let spellcards=5;
let spellcardnumber=21;
let damagerate=10;
let outfit=6;
outfit=(128*outfit)-128;
let usespell=0;
let bgfade=0;
let frame=0;
let time=0;
let miny=GetClipMinY; let maxy=GetClipMaxY; let minx=GetClipMinX; let maxx=GetClipMaxX;
let cx=GetCenterX; let cy=GetCenterY;

let SEshotb7=("\script\SoundEffects\shotb7.wav");
let SElaserm3=("\script\SoundEffects\laserm3.wav");
let SEcharge1=("\script\SoundEffects\charge1.wav");

let BG1=("\script\Images\BackgroundLayers\Kurumi1.png");
let GRboss=("\script\Images\CharacterSprites\Kurumi.png");

#include_function "script/Functions/SetSpellcardCommonData.txt";
#include_function "script/Functions/SpellcardNameLoad.txt";
#include_function "script/Functions/HealthBarLoad.txt";
#include_function "script/Functions/CutInLoad.txt";

@Initialize{
	LoadUserShotData("script\shots\ShotsKurumi1.txt");

	LoadSE("\script\SoundEffects\shotb7.wav");
	LoadSE("\script\SoundEffects\laserm3.wav");
	LoadSE("\script\SoundEffects\charge1.wav");
	
	LoadGraphic("\script\Images\CharacterSprites\Kurumi.png");
	LoadGraphic("\script\Images\BackgroundLayers\Kurumi1.png");

	SetScore(250000);
	SetLife(600);
	SetTimer(50);
	SetInvincibility(120);
	SetDamageRate(10,10);
	SetEnemyMarker(true);
	MagicCircle(true);
	#include_function "script/Functions/Focus.txt";
	Focus(character);
	SetEffectForZeroLife(60,100,1);
	SetMovePosition02(cx,miny+100,50);
}
	
@MainLoop{

SetCollisionA(GetX,GetY,16);
SetCollisionB(GetX,GetY,16);
SetShotAutoDeleteClip(32,32,32,32);

Weakness(character);
#include_function "script/Functions/Weakness.txt";
if(GetCommonData("BombOn")==0){ damagerate=10; }
if(GetCommonData("BombOn")==1){ damagerate=7; }
SetDamageRate(damagerate*weaken,damagerate*weaken);

let difficulty="";
if(GetCommonDataDefault("Difficulty",2)==1){ difficulty="Easy"; }
if(GetCommonDataDefault("Difficulty",2)==2){ difficulty="Normal"; }
if(GetCommonDataDefault("Difficulty",2)==3){ difficulty="Hard"; }
if(GetCommonDataDefault("Difficulty",2)==4){ difficulty="Lunatic"; }

SpellcardName("Intimidation [Coercion] ("~difficulty~")",spellcardnumber); 
HealthBar();
Portrait(cutin,1);


if(time%60==0 && time>=60 && phase2==1 && stopshoot==0){
let angle=rand(0,360);
	loop(55){
	if(time%120==0){ CreateShot01(GetX,GetY,1.5,angle,8,0); }
	if(time%120!=0){ CreateShot01(GetX,GetY,1.5,angle,80,0); }
	angle+=360/55;
	}
PlaySE(SEshotb7);
usespell=21;
}
if(time%45==0 && time>=60 && phase2==2 && stopshoot==0){
let angle=rand(0,360);
	loop(55){
	if(time%90==0){ CreateShot01(GetX,GetY,2,angle,8,0); }
	if(time%90!=0){ CreateShot01(GetX,GetY,2,angle,80,0); }
	angle+=360/55;
	}
PlaySE(SEshotb7);
usespell=21;
}
if(time%30==0 && time>=60 && phase2==3 && stopshoot==0){
let angle=rand(0,360);
	loop(55){
	if(time%60==0){ CreateShot01(GetX,GetY,2.3,angle,8,0); }
	if(time%60!=0){ CreateShot01(GetX,GetY,2.3,angle,80,0); }
	angle+=360/55;
	}
PlaySE(SEshotb7);
usespell=21;
}
if((GetLife>=250 && GetLife<500) || (GetTimer>=15 && GetTimer<35) && phase2==1){ if(phase2==1){ stopshoot=90; } phase2=2;  }
if(GetLife<250 || GetTimer<20 && phase2==2){  if(phase2==2){ stopshoot=90; } phase2=3; }
if(stopshoot==90){
	SetColor(190,255,60);
	Concentration01(90);
	SetColor(255,255,255);
	PlaySE(SEcharge1);
}
if(stopshoot>0){ stopshoot--; }
if(stopshoot<0){ stopshoot=0; }

if(shots>=11 && phase%2==0){ phase++; xpos=maxx; ypos=miny; shots=0; frame=50; }
if(shots>=11 && phase%2!=0){ phase++; xpos=minx+(maxx-minx)/22;  ypos=miny+(maxy-miny)/22; shots=0; frame=50; }

if(frame>=60 && time%12==0 && phase%2==0 && shots<11){
	CreateLaser01(xpos,miny,3,90,200,20,61,0);
	xpos+=(maxx-minx)/10;
	CreateLaser01(minx,ypos,3,0,200,20,61,0);
	ypos+=(maxy-miny)/10;
	shots++;
PlaySE(SElaserm3);
}

if(frame>=60 && time%12==0 && phase%2!=0 && shots<11){
	CreateLaser01(xpos,miny,3,90,200,20,63,0);
	xpos-=(maxx-minx)/10;
	CreateLaser01(maxx,ypos,3,180,200,20,63,0);
	ypos+=(maxy-miny)/10;
	shots++;
PlaySE(SElaserm3);
}


time++; frame++;
if(usespell>0){ usespell--; } if(usespell<0){ usespell++; }
SetCommonData("Boss1X",GetX); SetCommonData("Boss1Y",GetY);

#include_function "script/Functions/SpellcardName.txt";
#include_function "script/Functions/HealthBar.txt";
#include_function "script/Functions/CutIn.txt";
}

@BackGround{
	if(bgfade<255){ bgfade+=5; }
	SetGraphicRect(0,0,50,1200);
	SetTexture(BG1);
	SetAlpha(bgfade);
	SetColor(255,255,255);
	SetRenderState(ALPHA);
	SetGraphicScale(0.6,0.6); SetGraphicAngle(0,0,-10); DrawGraphic(cx-100,cy);
	SetGraphicScale(0.7,0.7); SetGraphicAngle(0,0,30); DrawGraphic(cx-100,cy);
	SetGraphicScale(0.8,0.8); SetGraphicAngle(0,0,70); DrawGraphic(cx+100,cy);
	SetGraphicScale(0.9,0.9); SetGraphicAngle(0,0,120); DrawGraphic(cx-40,cy);
	SetGraphicScale(1,1); SetGraphicAngle(0,0,160); DrawGraphic(cx+120,cy);
	SetGraphicScale(1.1,1.1); SetGraphicAngle(0,0,10); DrawGraphic(cx+70,cy);
	SetGraphicScale(1.2,1.2); SetGraphicAngle(0,0,100); DrawGraphic(cx,cy+150);
	SetGraphicScale(1.3,1.3); SetGraphicAngle(0,0,80); DrawGraphic(cx,cy-150);
}

@DrawLoop{
	SetGraphicScale(1,1);
	SetTexture(GRboss);
	SetGraphicAngle(0,0,0);
	SetColor(255,255,255);
	SetRenderState(ALPHA);

	if(usespell>=1){ SetGraphicRect(384,outfit,512,outfit+128); }
	if(usespell<=-1){ SetGraphicRect(512,outfit,640,outfit+128); }
	if(usespell==0){
		if(GetSpeedX<=0.5 && GetSpeedX>=-0.5){ SetGraphicRect(0,outfit,128,outfit+128); }
		else if(GetSpeedX<-0.5){ SetGraphicRect(128,outfit,256,outfit+128); }
		else if(GetSpeedX>0.5){ SetGraphicRect(256,outfit,384,outfit+128); }
	}
	DrawGraphic(GetX,GetY);
}

@Finalize{
//	SetCommonData("Conversation",1);
	NewPointData(spellcardnumber,GetCommonData("Difficulty"));
	#include_function "script/Functions/Main Menu/SpellcardDataAndPoints.txt";
}

}